<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>事件的冒泡</title>
		<style type="text/css">
			html,body{
				width: 100%;
				height: 100%;
			}
		</style>
	</head>
	<body>
		<div id="d1" style="background: #0000ff;width: 800px;height: 600px;">
			<div id="d2" style="background: #00ff00;width: 400px;height: 300px;">
				<div id="d3" style="background: #ff0000;width: 200px;height: 150px;">
					
				</div>
				
			</div>
		</div>
		
	</body>
</html>

<script type="text/javascript">
	window.onload = ()=>{
		d1 = document.getElementById("d1")
		d2 = document.getElementById("d2")
		d3 = document.getElementById("d3")
		//true表示在捕捉阶段响应，顺序为d1→d2→d3。由外及内
		//false或者不写表示冒泡阶段响应，顺序为d3→d2→d1，由内及外
		d1.addEventListener("click",(event)=>{
			alert("d1响应");
		},false)
		d2.addEventListener("click",(event)=>{
			alert("d2响应");
		},false)
		d3.addEventListener("click",(event)=>{
			alert("d3响应");
		},false)
	}
</script>
